***This do-file creates Figure 3 of the paper
**Curtis RESTAT
**Change to directory where data and code were downloaded
**cd 

clear all
set matsize 9000
set maxvar 9000

clear
use cbp_big_figure4

rename state stateabb
rename fipstate state
so state year


drop ind1-ind21
so naics
qui tab naics3,gen(ind)
foreach x of varlist ind1-ind21 {
qui gen postxeastx`x'=postxeast*`x'
qui drop if postxeastx`x'==.
}

	qui tab ctyid, gen(ctydum)
	forvalues i = 1(1)3117 {
	  qui replace ctydum`i' = ctydum`i'*trend
	 }
	forvalues i = 1(1)3117 {
	  qui rename ctydum`i' ctytrend`i'
	 }
	forvalues i = 1(1)21 {
	  qui replace ind`i'= ind`i'*trend
	 }
	forvalues i = 1(1)21 {
	  qui rename ind`i' indtrend`i'
	 }
tostring east,gen(NBP)
gen NBPind=NBP+naics3
qui areg lemp_imp postxeastxind* postxeast postxint intxeast  ctytrend* indtrend* y1-y11, abs(ctyind) rob cluster(NBPind)
parmest,norestore

keep in 1/21

gen ind_num=substr(parm,14,.)
so ind_num

merge 1:1 ind_num using ind_names_figure4
gen pos=3
drop if ind_num=="6"
replace pos=1 if naics_name=="Transportation Equipment"
replace pos=5 if naics_name=="Chemicals"
replace pos=5 if naics3==337
replace pos=3 if naics3==311
replace pos=1 if naics3==313
replace pos=1 if naics3==339
replace pos=11 if naics3==333
replace pos=4 if naics3==315
replace pos=6 if naics3==316
replace pos=6 if naics3==331
replace pos=6 if naics3==327
twoway (scatter estimate en_int,mlabel(naics_name) mlabv(pos)) (lfit estimate en_int, play(fig4edit.grec)) 



